package com.peter.springcloud.eurekaconsumer.ribbon.hystrix;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@EnableHystrixDashboard // 开启Hystrix Dashboard，一个集群中一个就够了。
@EnableCircuitBreaker // 注解开启Hystrix的使用，当然我们也可以使用另一个注解：@EnableHystrix，凡是需要“断路器”的应用都需要它！
@EnableDiscoveryClient
@SpringBootApplication
public class Application {
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static void main( String[] args ) {
        new SpringApplicationBuilder(Application.class).web(true).run(args);
    }
}
